-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Copying the messages and marking a message in between as unread generates 'new' in the text #18228
Fix: Copying the messages and marking a message in between as unread generates 'new' in the text #18228
Conversation
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
@Beamanator @fedirjh One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Reviewer Checklist
Screenshots/VideosWebScreen.Recording.2023-05-01.at.10.07.13.PM.movDesktopScreen.Recording.2023-05-01.at.10.08.34.PM.mov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
cc @Beamanator All yours
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 💪
Co-authored-by: Alex Beaman <dabeamanator@gmail.com>
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/Beamanator in version: 1.3.9-12 🚀
|
@AndrewGable I'm currently investigating the unintended behavior. Thanks. |
cc @Beamanator , @Victor-Nyagudi ProblemDuring my investigation of this regression, I discovered that a top-level (or "parent") SolutionWe should check for nested elements that have a // Query all non selectable element that doesn’t have any child that have a selectable text
div.querySelectorAll('*[style*="user-select: none"]:not(:has(*[style*="user-select: text"]))')
.forEach(item => item.remove()); |
I was just about to post my findings as you posted yours, @fedirjh. ProblemI also discovered there are a couple of other components that have the One of the bigger components being App/src/components/OfflineWithFeedback.js Line 76 in b6eb637
App/src/components/OptionRow.js Line 160 in b6eb637
SolutionI explored two possible solutions with the first being the one I went with, and the second being one that could require a bit more work but is more future-proof, however, I'd require some input on it first.
From my search using VS Code's search tool, I discovered the only component using Given only one message can be marked unread at a time and the single use-case scenario mentioned above, I opted to just grab the // Get the div housing the UnreadActionIndicator and remove it from copied content
div.querySelector(`[aria-label="${Localize.translateLocal('accessibilityHints.newMessageLineIndicator')}"]`)
.remove(); Should things change in future and multiple messages can be marked as unread, we can update this to Here are a couple of videos with my changes applied. Mac Chrome Englishexpensify-mac-chrome-unread-message-english.movMac Chrome Spanishexpensify-mac-chrome-unread-message-spanish.movMac Safari Englishexpensify-mac-safari-unread-message-english.movMac Safari Spanishexpensify-mac-safari-unread-message-spanish.movMac Desktop Englishexpensify-mac-desktop-unread-message-english.movMac Desktop Spanishexpensify-mac-desktop-unread-message-spanish.movThis is a very specific fix, though, and only covers As you can see, the emojis are now being copied again. In the previous solution in this PR that caused a regression, the emojis weren't being copied, so it looks like we may have been onto something in possibly fixing other issues involving copying emojis or inadvertently copying text. On the other hand, I don't think it would be a bad idea to focus on one issue at a time, and then propose solutions to the other copying issues once this one is fixed with no regressions.
I dabbled with the idea of components that should not be copied receiving a We could then go through all the elements with this attribute set to div.querySelectorAll(`div[data-shouldElementBeCopiedToClipboard="${shouldElementBeCopiedToClipboard}"]`)
.forEach(item => item.remove()); I like @fedirjh proposal though. We could also go with that. Support for cc: @Beamanator P.S. Notice how in the videos I've shared in this comment how copying the messages from the left side to right doesn't copy the emojis (text cursor is visible) but copying from the right side to left (default cursor) does. Just some food for thought going forward. |
@fedirjh @Victor-Nyagudi I previously mentioned that this bug is a browser bug here #15194 (comment), but looks like everyone disagree with it (the bug isn't reproducible in Firefox). You can found the Chromium bug report from my comment. At first, I thought it's already fixed on the latest version of Chrome, but turns out it's still reproducible and also the commits getting reverted because of a regression. I think the commit could be useful especially the test case. If I understand @fedirjh solution correctly, it will select the non selectable text for this case:
Result: SKIP KEEP However, based on the chromium test case, only KEEP text should be copied. Here is one of the test case example on nested user-select I think it would require a lot of changes to cover all cases without any regression. Even the chromium commits getting reverted 🤣. So, if I can suggest, I would go for the solution to only exclude the text on a specific component in the meantime, in this case the new message indicator, while waiting the full fix from Chromium, which I guess will be taking very long, not to mention Safari. |
Thank you for the thorough investigation, @bernhardoj. Your explanation is very helpful. I suggest that we go with @Victor-Nyagudi's option 1, which will only exclude the text on a specific component, |
🚀 Deployed to production by https://github.com/roryabraham in version: 1.3.12-0 🚀
|
I'm a little confused here. This PR was reverted by @AndrewGable but has been deployed to production. Is it the reverted PR that's been deployed to production and we're just being notified, or did something happen in between? |
@Victor-Nyagudi yeah i can see that it's confusing, I looked at the changes made by the revert PR, and they're what's currently in the |
@fedirjh I agree with this conclusion 👍 Since @Victor-Nyagudi is the author of this PR (which was reverted), @Victor-Nyagudi can you please make the fix PR & link it to the original issue & mention this one as well? |
@Beamanator Got it. I'll get to work on the PR. Glad that's cleared up. |
Thanks @Victor-Nyagudi 👍 |
PR is ready for review. Let me know if there's anything else you need me to do. cc: @fedirjh @Beamanator |
Details
Added the
styles.userSelectNone
style toUnreadActionIndicator
so users are visually aware it's not copied to the clipboard and then removed all elements with this style applied from the copied contents insideSelectionScraper
.This way, anything that's given a style of
user-select: none
is omitted from the clipboard whenever the user copies something.Fixed Issues
$ #17838
$ #17838 (comment)
Tests
New
that's to the right of the green line is not highlightedNew
is not part of pasted contentread
Offline tests
Same as above but go offline after logging in i.e. step 1 (or force offline in staging).
QA Steps
Same as Tests.
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
expensify-mac-chrome-paste-without-new-word.mov
expensify-mac-safari-paste-without-new-word.mov
Mobile Web - Chrome
Mobile Web - Safari
Desktop
expensify-mac-desktop-paste-without-new-word.mov
iOS
Android